package com.naiterui.ehp.bs.agent.service.impl;

import org.springframework.stereotype.Service;

import com.naiterui.common.repository.page.PageParamVO;
import com.naiterui.common.repository.page.PageVO;
import com.naiterui.ehp.bp.bo.statistics.DataReportBO;
import com.naiterui.ehp.bp.bo.statistics.DataReportInviteBO;
import com.naiterui.ehp.bp.bo.statistics.DataReportProductBO;
import com.naiterui.ehp.bp.bo.statistics.DataReportRecipelBO;
import com.naiterui.ehp.bs.agent.feign.ICmsapiFeignClient;
import com.naiterui.ehp.bs.agent.service.IDataReportService;

import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 数据报表
 * 
 * @author yangfuya
 * @since 2022/2/18
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DataReportServiceImpl implements IDataReportService {
    private final ICmsapiFeignClient cmsapiFeignClient;

    @Override
    public DataReportBO index(Long agentId) {
        DataReportBO reportIndex = cmsapiFeignClient.getDateReportIndex(agentId);
        log.info("index : {}", JSONUtil.toJsonStr(reportIndex));
        return reportIndex;
    }

    @Override
    public DataReportRecipelBO getRecipel(Long agentId, Integer reportType, String reportDate) {
        DataReportRecipelBO recipelDateReport = cmsapiFeignClient.getRecipelDateReport(agentId, reportType, reportDate);
        log.info("recipel : {}", JSONUtil.toJsonStr(recipelDateReport));
        return recipelDateReport;
    }

    @Override
    public PageVO<DataReportProductBO> getProduct(PageParamVO paramVO, Long agentId, Integer reportType,
        String reportDate) {
        PageVO<DataReportProductBO> productPage =
            cmsapiFeignClient.getProductPage(paramVO.getPage(), paramVO.getNum(), agentId, reportType, reportDate);
        log.info("productPage : {}", JSONUtil.toJsonStr(productPage));
        return productPage;
    }

    @Override
    public DataReportInviteBO getInvite(Long agentId, Integer reportType, String reportDate) {
        DataReportInviteBO inviteDataReport = cmsapiFeignClient.getInviteDataReport(agentId, reportType, reportDate);
        log.info("invite :{}", JSONUtil.toJsonStr(inviteDataReport));
        return inviteDataReport;
    }
}
